home *** CD-ROM | disk | FTP | other *** search
- Path: sunrise.gv.ssi1.com!news
- From: Mike Palmer <Mike.Palmer@tus.ssi1.com>
- Newsgroups: comp.lang.c++
- Subject: Re: accessing the printer or serial port
- Date: 5 Mar 1996 01:43:12 GMT
- Organization: Silicon Systems, Inc.
- Message-ID: <4hg67g$65t@atlas.tus.ssi1.com>
- References: <31387AFD.7184@gramercy.ios.com>
- NNTP-Posting-Host: pc259u.tus.ssi1.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
-
- Storm Orisak <stormer@gramercy.ios.com> wrote:
- >Could someone please post the command to send bits out through the
- >serial or parallel port in MSVC 4.0.
- >
- >Thanks
-
- I presume you are using an IBM compatible PC (someone around here is trying to do
- this on an HP workstation, and finding it to be much more difficult...)
-
- If you want to write to the printer, the easiest way to do it is to use DOS or BIOS
- services. That stuff is pretty well documented in many books, so I won't describe it
- in more detail here.
-
- If you want to actually write bits out, and you don't want any extra handshaking or
- anything else (in my application, I use the parallel port to talk to a port on an IC
- we designed, so I just want to be able to make the parallel port pins go high and
- low at my command).
-
- For the parallel port, the command you want is outportb(). You hand it a port number
- and a byte, and it puts it out directly. The port locations can be found using
- debug: have it dump the memory at 0040:0000. The last eight bytes on the first line
- of the dump are the ports for the installed parallel ports. In the listing below
- (from my computer), 78 03 is the port 0x0378 (LPT1). The reason you should find the
- port addresses at this memory location is that they can be at different locations on
- different computers. In some IBM PS/2 computers, for example, LPT1 is at a different
- port.
-
- 0040:0000 F8 03 F8 02 00 00 00 00-78 03 00 00 00 00 00 00 ........x.......
-
- Then, you just write to that port using outportb, and whatever you write appears
- there.
-
- There is no similar way to output specific bits in this manner from the serial port,
- and although I did some serial port programming years ago, I can't remember enough
- of it to be helpful...
-
- Hope the information I've provided helps...
-
- -- Mike --
-
-
-
-
-
-